package com.tank.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.tank.bean.Notice;
import com.tank.dao.NoticeDAO;
import com.tank.service.NoticeService;
import com.tank.util.Pager;
import com.tank.util.TankUtil;

@Service("noticeService")
public class NoticeServiceImpl implements NoticeService {
	@Autowired
	@Qualifier("ndao")
	NoticeDAO dao;
	
	public Pager findNoticeList() {
		return dao.findNoticeList();
	}

	public void addNotice(Notice n) {
		n.setAuthor("system");
		n.setPubtime(new Date());
		//n.setType(Notice.Buddy);
		n.setContent(n.getContent().replaceAll("#link:master#", "<a href=\"itemsProfileAction.action?userId="+n.getMaster().getId()+"\">"+n.getMaster().getName()+"</a> "));
		System.out.println(n.getContent());
		System.out.println(dao);
		dao.save(n);
	}

	public void removeNotice(Notice n) {
		System.out.println(dao);
		dao.remove(n);
	}


}
